<template>
  <section class="todo-input">
    <input
      type="text"
      placeholder="请输入需要添加的事项"
      v-model="text"
      @keydown.enter="addItem"
    />
    <button @click="addItem">添加</button>
  </section>
</template>
<script>
export default {
  data() {
    return {
      text: "",
    };
  },
  methods: {
    addItem() {
      this.$emit("addItem", this.text);
      this.text = "";
    },
  },
};
</script>